package config

import "public.com/goutil/configUtil"

// 功能开关配置
type FunctionConfig struct {
	// 组队副本是否在一次比赛完成后，解散队伍,默认为true
	TeaBattle_IfDismissTeam bool

	// 组队战斗类型
	TeamBattle_FightType string

	// 队伍超时时间 秒
	TeamBattle_TimeoutTime int

	// 是否推送超时队伍到game server
	TeamBattle_IfPushTimeoutTeam bool

	// 游戏代码
	GameCode string
}

var (
	// 功能开关配置对象
	functionConfigObj *FunctionConfig
)

// 加载功能开关配置
func initFunctionConfig(configObj *configUtil.XmlConfig) error {
	attrName := "Value"
	basePath := "root/FunctionConfig"
	functionConfigObj = &FunctionConfig{}

	functionConfigObj.TeaBattle_IfDismissTeam = configObj.DefaultBool(basePath+"/TeamBattle_IfDismissTeam", attrName, true)
	functionConfigObj.TeamBattle_FightType = configObj.DefaultString(basePath+"/TeamBattle_FightType", attrName, "3V1")
	functionConfigObj.TeamBattle_IfPushTimeoutTeam = configObj.DefaultBool(basePath+"/TeamBattle_IfPushTimeoutTeam", attrName, false)
	functionConfigObj.TeamBattle_TimeoutTime = configObj.DefaultInt(basePath+"/TeamBattle_TimeoutTime", attrName, 2*60*60)
	functionConfigObj.GameCode = configObj.DefaultString(basePath+"/GameCode", attrName, "qyc")

	return nil
}

// 获取功能开关配置对象
func GetFunctionConfigObj() *FunctionConfig {
	return functionConfigObj
}
